# Maintainer: Rafal Brzegowy <rafal.brzegowy@yahoo.com>

_realname=parsec
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1.0.r3811.ge3360fad5
pkgrel=1
pkgdesc='PaRSEC: Parallel Runtime Scheduling and Execution Controller (mingw-w64)'
arch=('any')
depends=()
makedepends=("flex"
             "bison"
             "${MINGW_PACKAGE_PREFIX}-hwloc"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-ninja")
license=('custom')
url='http://icl.utk.edu/parsec/'
_commit='e3360fad5ecfa91e7e090ecdee0dca37f5708326'
source=("${_realname}"::"git+https://bitbucket.org/icldistcomp/${_realname}#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "${_realname}"
  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  #Static Build
  [[ -d "${srcdir}/build-${MINGW_CHOST}-static" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}-static"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}-static" && cd "${srcdir}/build-${MINGW_CHOST}-static"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
    ${MINGW_PREFIX}/bin/cmake \
    -G'Ninja' \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF \
    -DPARSEC_GPU_WITH_CUDA=OFF \
    -DPARSEC_WITH_DEVEL_HEADERS=ON \
    -DBUILD_SHARED_LIBS=OFF \
    -DPARSEC_DIST_WITH_MPI=OFF \
    -DEXTRA_LIBS="-lwsock32 -lws2_32" \
    -DBUILD_TESTING=OFF \
    ../${_realname}
  ninja
}

package() {
  #Static Install
  cd "${srcdir}/build-${MINGW_CHOST}-static"
  DESTDIR=${pkgdir} ninja install
  install -Dm644 ${srcdir}/${_realname}/License.txt ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
